// To parse this JSON data, do
//
//     final homeMo = homeMoFromJson(jsonString);

import 'dart:convert';

import 'package:bilibili/http/model/video_model.dart';

import 'banner_mo.dart';

HomeMo homeMoFromJson(String str) => HomeMo.fromJson(json.decode(str));

class HomeMo {
  List<BannerMo>? bannerList;
  List<CategoryList>? categoryList;
  List<VideoModel>? videoList;

  HomeMo({
    required this.bannerList,
    required this.categoryList,
    required this.videoList,
  });

  factory HomeMo.fromJson(Map<String, dynamic> json) => HomeMo(
        bannerList: List<BannerMo>.from(
            json["bannerList"]?.map((x) => BannerMo.fromJson(x)) ?? []),
        categoryList: List<CategoryList>.from(
            json["categoryList"]?.map((x) => CategoryList.fromJson(x)) ?? []),
        videoList: List<VideoModel>.from(
            json["videoList"]?.map((x) => VideoModel.fromJson(x)) ?? []),
      );

  Map<String, dynamic> toJson() => {
        "bannerList": bannerList?.map((x) => x.toJson()).toList(),
        "categoryList": categoryList?.map((x) => x.toJson()).toList(),
        "videoList": videoList?.map((x) => x.toJson()).toList(),
      };
}

class CategoryList {
  String name;
  int count;

  CategoryList({
    required this.name,
    required this.count,
  });

  factory CategoryList.fromJson(Map<String, dynamic> json) => CategoryList(
        name: json["name"],
        count: json["count"],
      );

  Map<String, dynamic> toJson() => {
        "name": name,
        "count": count,
      };
}
